package com.shine.app.commons;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.shine.app.bean.GolfTeeTimeBean;

public class Convert {

	private static Convert convert;

	public static Convert getConvert() {
		if (convert == null) {
			synchronized (Convert.class) {
				if (convert == null) {
					convert = new Convert();
				}
			}
		}
		return convert;
	}

	public List<String> getTextList(String str_array[]) {
		List<String> text = new ArrayList<String>();
		for (int i = 0, len = str_array.length; i < len; i++) {
			text.add(str_array[i]);
		}
		return text;
	}

	public List<Integer> getImgList(int[] img_array) {
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0, len = img_array.length; i < len; i++) {
			list.add(img_array[i]);
		}
		return list;
	}

	public double converDouble(double number) {
		double result = 0;
		BigDecimal bg = new BigDecimal(number);
		result = bg.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
		return result;
	}

	public List<GolfTeeTimeBean> converTeeTimeList(GolfTeeTimeBean[] teeTimes) {
		List<GolfTeeTimeBean> list = new ArrayList<GolfTeeTimeBean>();
		for (int i = 0, length = teeTimes.length; i < length; i++) {
			list.add(teeTimes[i]);
		}
		return list;
	}

	public List<GolfTeeTimeBean> converTeeTimeSorts(GolfTeeTimeBean[] teeTimes) {
		List<GolfTeeTimeBean> list = new ArrayList<GolfTeeTimeBean>();
		for (int i = 0, length = teeTimes.length; i < length; i++) {
			if (i % 2 == 0) {
				list.add(teeTimes[i]);
			}
		}
		for (int i = 0, length = teeTimes.length; i < length; i++) {
			if (i % 2 != 0) {
				list.add(teeTimes[i]);
			}
		}
		return list;
	}

}
